package NC111_最大数;

import java.util.*;


public class Solution {
    /**
     * 最大数
     * @param nums int整型一维数组
     * @return string字符串
     */
    public String solve (int[] nums) {
        // write code here
        ArrayList<String> list = new ArrayList<>();
        // 将整形的数字转化为字符串
        for (int num : nums) {
            list.add(String.valueOf(num));
        }

        // 排序
        list.sort(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return (o2 + o1).compareTo(o1 + o2);
            }
        });
        if (list.get(0).equals("0")){
            return "0";
        }

        StringBuilder sb = new StringBuilder();
        for (String s : list) {
            sb.append(s);
        }
        return sb.toString();
    }
}